home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tde210.zip / CFGHELP.C < prev    next >
C/C++ Source or Header  |  1992-11-13  |  2KB  |  94 lines

  1. /*
  2.  * This module contains all the routines needed to create a new help
  3.  * screen.  The new help screen is read from a file which must exist before
  4.  * executing this routine.
  5.  *
  6.  * Program Name:  tdecfg
  7.  * Author:        Frank Davis
  8.  * Date:          October 5, 1991
  9.  */
  10.  
  11. #include <io.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15.  
  16. #include "tdecfg.h"
  17. #include "cfghelp.h"
  18.  
  19. extern struct vcfg cfg;
  20. extern FILE *tde_exe;                  /* FILE pointer to tde.exe */
  21.  
  22. static WINDOW *w_ptr;
  23.  
  24.  
  25. /********    EXTREMELY IMPORTANT   ************/
  26. /*
  27.  * If you modify tde, it is your responsibility to find the offset of
  28.  * the help screen in your new executable, tde.exe.
  29.  *
  30.  */
  31.  
  32.  
  33.  
  34. /*
  35.  * Name:    tdehelp
  36.  * Date:    October 1, 1991
  37.  * Notes:   Set up most of the window global variables.
  38.  */
  39. void tdehelp( void )
  40. {
  41. int c;
  42. int i;
  43. char line[200];
  44. char out_line[82];
  45. char fname[82];
  46. char *rc;
  47. FILE *help_file;                  /* FILE pointer to help screen */
  48. long offset;
  49.  
  50.  
  51.    cls( );
  52.    show_box( 0, 0, help_screen, NORMAL );
  53.    xygoto( 42, 14 );
  54.    c = getkey( );
  55.    while (c != '1' && c != '2')
  56.       c = getkey( );
  57.    if (c == '1') {
  58.       puts( "" );
  59.       puts( "" );
  60.       puts( "" );
  61.       puts( "Enter file name that contains new help screen :" );
  62.       gets( fname );
  63.       if ((c = access( fname, EXIST )) != 0) {
  64.          puts( "\nFile not found.  Press any key to continue." );
  65.          c = getkey( );
  66.          cls( );
  67.          return;
  68.       } else if ((help_file = fopen( fname, "r" )) == NULL ) {
  69.          puts( "\nCannot open help file.  Press any key to contine." );
  70.          c = getkey( );
  71.          cls( );
  72.          return;
  73.       }
  74.       offset = HELP_OFFSET;
  75.       rc = fgets( line, 100, help_file );
  76.       for (c=0; c<25 && rc != NULL; c++) {
  77.          memset( out_line, '\0', 82 );
  78.          for (i=0; i<80 && line[i] != '\n'; i++)
  79.              out_line[i] = line[i];
  80.          fseek( tde_exe, offset, SEEK_SET );
  81.          fwrite( out_line, sizeof( char ), 81, tde_exe );
  82.          offset += 81;
  83.          rc = fgets( line, 100, help_file );
  84.       }
  85.       fclose( help_file );
  86.       puts( "" );
  87.       puts( "" );
  88.       puts( "" );
  89.       puts( "New help screen successfully installed.  Press any key to continue." );
  90.       c = getkey( );
  91.    }
  92.    cls( );
  93. }
  94.